package com.llyb.controller;

import com.llyb.entities.User;
import com.llyb.result.ResultData;
import com.llyb.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("user/{id}")
    public ResultData<User> getUserById(@PathVariable("id") Integer id){
        return ResultData.success(userService.getById(id));
    }

    @PostMapping("user/add")
    public ResultData<Boolean> addUser(@RequestBody User user){
        return ResultData.success(userService.save(user));
    }


}
